<template>
	<div class="body_inner">

		<div class="notice_page">
			<div class="page_top">
				<a href="/mypage"><i class="xi-arrow-left"></i></a>

				<div class="allMenu_btn" v-if="!allMenuShow" @click="allMenuShow = true">
					<div class="x"></div>
					<div class="y"></div>
					<div class="z"></div>
				</div>
				<div class="allMenu_btn open" v-if="allMenuShow" @click="allMenuShow = false">
					<div class="x coll rotate30 rotate45"></div>
					<div class="y coll" style="display: none;"></div>
					<div class="z coll rotate150 rotate135"></div>
				</div>
			</div>

			<div class="page_contents">
				<h3>
					공지사항
					<p>스노우씨드에서 알려드립니다.</p>
				</h3>

				<div class="notice_box" v-for="(value,index) in list" :key="index">
					<div class="title" @click="showContent(index)">
						<p>
							{{value.name}}
							<span>{{value.create_time}}</span>
						</p>
						<i class="xi-angle-down"></i>
					</div>

					<p class="text" style="display: block;" v-if="value.show" v-html="value.content"></p>
				</div>

			</div>
		</div>

		<nav id="allMenu" v-if="allMenuShow">
			<ul>
				<li>
					<a href="/main">
						<p><i class="xi-home"></i>홈</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/staking">
						<p><i class="xi-bank"></i>상품 구매</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/staking_sum">
						<p><i class="xi-credit-card"></i>상품 구매 합계</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/interest">
						<p><i class="xi-piggy-bank"></i>데일리내역</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/withdraw_apply">
						<p><i class="xi-money"></i>출금신청</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/withdraw_list">
						<p><i class="xi-wallet"></i>출금/송금내역</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/recommender">
						<p><i class="xi-group"></i>추천인 목록</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>

				<li>
					<a href="/mypage">
						<p><i class="xi-profile-o"></i>마이페이지</p>
						<i class="xi-angle-right-min"></i>
					</a>
				</li>
			</ul>

			<div class="btn" @click="logout()">로그아웃</div>
		</nav>
	</div>
</template>
<script>
	import axios from "axios";
	export default {
		data() {
			return {
				list: [],
				allMenuShow: false
			};
		},
		created() {
			this.getList();
		},
		methods: {
			getList() {
				var _this = this;
				axios.post('https://admintest.pdt-daily.com/api/notice/notice_list', {}, {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded',
						'Access-Token': localStorage.getItem('token')
					}
				}).then(function(response) {
					console.log(response);
					if (response.data.status == 401) {
						_this.$router.push('/login');
					}
					for (var i = 0; i < response.data.data.list.data.length; i++) {
						response.data.data.list.data[i].show = false;
					}
					_this.list = response.data.data.list.data;
				}).catch(function(error) {
					console.log(error);
				});
			},
			showContent(index) {
				// for(var i=0;i<this.list.length;i++){
				// 	this.list[i].show = false;
				// }
				this.list[index].show = !this.list[index].show;
			},
			logout() {
				var _this = this;
				axios.post('https://admintest.pdt-daily.com/api/user/logout', {}, {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded',
						'Access-Token': localStorage.getItem('token')
					}
				}).then(function(response) {
					console.log(response);
					if (response.data.status == 200) {
						alert('로그아웃 되었습니다.');
						localStorage.setItem('token', '');
						_this.$router.push('/login');
					}
				}).catch(function(error) {
					console.log(error);
				});
			}
		},
	};
</script>